< previous page page_752 next page >

Page 752
After completing these steps, your form should look like the one shown in Figure 33.5. You are now ready to add code to the sample project.
0752-01.jpg
Figure 33.5
The Internet Transfer control does not appear
automatically in the Visual Basic Toolbox.
The Internet Transfer control has one event, the StateChanged event. The purpose of this event is to notify your program when different activities are happening. For example, the control is in one state when it is connecting to the Web server and in another when it is retrieving HTML. The current state is indicated by the State parameter of the event procedure. Enter the code for our sample program's StateChanged event, which is shown in Listing 33.3.
Listing 33.3 INETDEMO.ZIP Retrieving Raw HTML from a Web Server
Private Sub Inet1_StateChanged(ByVal State As Integer)
       
    Select Case State
        
        Case 12 'icResponseCompleted
            stemp = Inet1.GetChunk(100)
            While stemp <> ""
                Me.Print stemp;
                stemp = Inet1.GetChunk(100)
            Wend
            Me.Print
        
        Case 11 'icError
            MsgBox Inet1.ResponseInfo, vbCritical, "ERROR!"
    
    End Select

End Sub
Our code only handles two states, the icResponseCompleted state and the error state. The icResponseCompleted state indicates that the control has finished receiving a response from the Web server. The Internet Transfer control's GetChunk method is used to retrieve the response text from the buffer 100 bytes at a time and print it on the form.
note.gif A complete list of states and their meanings is in the online documentation article entitled "StateChanged Event." square.gif

 
< previous page page_752 next page >